[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
abs() Calculate Absolute Value of Integer
#include <stdlib.h> For function declarations
int abs(n);
int n; Integer value
abs() returns the absolute value of an integer, 'n', in the range 0
through 32767 (note: -32768 is returned as -32768).
Returns: Absolute value of 'n'
Note: If <stdlib.h> is included, and #undef abs() has not
been added to <stdlib.h>, then abs() will be treated
as a macro.
-------------------------------- Example ---------------------------------
The following statements calculate the absolute values of -15, 0 and
33.
#include <stdlib.h> /* Required for function declaration only
*/
main()
{
int x, y, z;
x = abs(-15); /* x = 15 */
y = abs(0); /* y = 0 */
z = abs(33); /* z = 33 */
}
See Also:
cabs()
fabs()
labs()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson